package ar.com.fiuba.domain.impl;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;

import ar.com.fiuba.application.impl.FileDataSource;
import ar.com.fiuba.domain.api.ErrorGenerator;

public class ErrorGeneratorTransposition extends ErrorGenerator {
	

	public ErrorGeneratorTransposition(String inputFileName, int numberOfWords)
	{
		super(inputFileName, numberOfWords);
	}
	
	
	public ArrayList<String> generateErrorAtTheBeginning()
	{
		ArrayList<String> wordsWithError = new ArrayList<String>();
		  for(String s:correctWordsArray){		  
			  String aux=s;
			  String sub1 = aux.substring(0,1);
			  String sub2 = aux.substring(1,2);
			  wordsWithError.add(sub2 + sub1 + aux.substring(2,aux.length()) );
		  }			  
		  return wordsWithError;
	}
	

	public ArrayList<String> generateErrorAtTheEnd()
	{
		ArrayList<String> wordsWithError = new ArrayList<String>();
		  for(String s:correctWordsArray){		  
			  String aux=s;
			  String sub1 = aux.substring(aux.length()-1,aux.length());
			  String sub2 = aux.substring(aux.length()-2,aux.length()-1);
			  wordsWithError.add(aux.substring(0,aux.length()-2) + sub1 + sub2 );
		  }			  
		  return wordsWithError;
	}
	
	public ArrayList<String> generateErrorInTheMiddle()
	{
		ArrayList<String> wordsWithError = new ArrayList<String>();
		  for(String s:correctWordsArray){		  
			  String aux=s;
			  String sub1 = aux.substring(1,2);
			  String sub2 = aux.substring(2,3);
			  wordsWithError.add(aux.substring(0,1) + sub2 + sub1 + aux.substring(2,aux.length()));
		  }			  
		  return wordsWithError;
	}

	
}
	
	